package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.DisputeBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IDisputeView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取矛盾纠纷
 */
public class DisputePest {

    private IDisputeView iDisputeView;

    public DisputePest(IDisputeView iDisputeView) {
        this.iDisputeView=iDisputeView;
    }


    /**
     *
     * @param url 地址类型
     * @param orgId 组织id
     * @param name 事件名称
     * @param issueKind 事件规模
     * @param eventSource 事件来源
     * @param entryTimeStart 开始时间
     * @param entryTimeEnd 结束时间
     * @param issueTypeId 事件类型主键
     * @param page 页数
     */
    public void getDisputeList(String url,String orgId ,String name ,String issueKind,String eventSource
            ,String entryTimeStart,String entryTimeEnd,String issueTypeId,int page,int rows){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("searchIssueVo.orgId", orgId);
        map.put("searchIssueVo.name",name);
        map.put("searchIssueVo.issueKind.id",issueKind);
        map.put("searchIssueVo.eventSource.id", eventSource);
        map.put("searchIssueVo.entryTimeStart", entryTimeStart);
        map.put("searchIssueVo.entryTimeEnd", entryTimeEnd);
        map.put("searchIssueVo.issueTypeId",issueTypeId);
        map.put("page", page);
        map.put("rows", rows);
        new ApiManager().getDisputeList(url,map, new BaseCallBack<BaseResult<DisputeBean>>() {
            @Override
            public void onSuccess(BaseResult<DisputeBean> response) {
                iDisputeView.getDisputeList(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iDisputeView.showError(message);
            }
        });
    }

    /**
     * 矛盾纠纷受理
     * @param issueStepId 事件步骤主键
     */
    public void disputeAccept(String issueStepId){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("issueStepId",issueStepId);
        new ApiManager().disputeAccept(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                if (response.data){
                    iDisputeView.accept("事件受理成功");
                }
            }
            @Override
            public void onFailures(String message) {
                iDisputeView.showError(message);
            }
        });
    }

    /**
     * * 更多矛盾纠纷处理
     * @param issueStepId 事件步骤主键
     * @param url 地址类型
     * @param id 事件id
     * @param content 意见
     * @param operationCode 督办编号(81:普通督办,83:黄牌督办,86:红牌督办)
     */
    public void disputeMoreDeal(String url,String id,String issueStepId,String content,int operationCode){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("id",id);
        map.put("issueStepId",issueStepId);
        map.put("logNew.content",content);
        map.put("operationCode",operationCode);
        new ApiManager().disputeDeal(url,map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                if (response.data){
                    iDisputeView.accept("事件处理成功");
                }
            }
            @Override
            public void onFailures(String message) {
                iDisputeView.showError(message);
            }
        });
    }

    /**
     * 删除
     */
    public void disputeMoreDeal(String url,String id){
        disputeMoreDeal(url,id,"","",0);
    }

    /**
     * 加急
     */
    public void disputeMoreDeal(String url,String issueStepId,String content){
        disputeMoreDeal(url,"",issueStepId,content,0);
    }
}
